<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Priorities {
    var $id;
var $priority;
var $time_due;
var $client_reminder;
var $alert_repeat;

    function __construct($priority,$time_due,$client_reminder,$alert_repeat) {
        $this->priority=$priority;
        $this->time_due=$time_due;
        $this->client_reminder=$client_reminder;
        $this->alert_repeat=$alert_repeat;
        $this->id=  $this->insert();
    }
    function open($id){
        global $db;
        $sql="select * from priorities where id=$id";
        $row=$db->fetch_row($sql);
        if (!empty($row)){
            extract($row);
            $this->priority=$priority;
            $this->time_due=$time_due;
            $this->client_reminder=$client_reminder;
            $this->alert_repeat=$alert_repeat;

        }
    }

    function openAll(){
        $sql="select * from priorities order by id asc";
        $result=$db->query($sql);
        return $db->fetch_array($result);
        
    }

    function insert(){
    global $db;
    $sql="insert into priorities values (null,'{$this->priority}',
'{$this->time_due}','{$this->client_reminder}','{$this->alert_repeat}')";
    $db->query($sql);
    return mysql_insert_id();
    }

    function update(){
        global $db;
        $sql="update priorities set priority='{$this->priority}',
time_due='{$this->time_due}',client_reminder='{$this->client_reminder}',
alert_repeat='{$this->alert_repeat}'
 where id={$this->id}";
        $db->query($sql);
    }

    function delete(){
        global $db;
        $sql="delete from priorities where id=".$this->id;
        $db->query($sql);
    }

}
?>
